package th.co.exat.uap.util.exception;

import java.text.NumberFormat;

public class UAPException {

    public static void nullValue(String value, String message) throws UAPNullValueException {
        if(value.equals("")) {
           throw new UAPNullValueException(message);
        }
    }

    public static void notNumber(String value, String message) throws UAPNotNumberException {
        try {
            NumberFormat.getInstance().parse(value);
        } catch (Exception e) {
            throw new UAPNotNumberException(message);
        }
    }

    public static void payRange(int pay, int rate, String message) throws UAPPayRangeException {
        if(pay < 0 || pay >= rate) {
            throw new UAPPayRangeException(message);
        }
    }
}
